/*
 * ===================================================
 *
 *       Filename:  opt_short.c
 *
 *
 *        Created:  10/09/2011 04:02:08 AM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  durand_y, <durand.yoan@gmail.com>
 *
 * ===================================================
 */
#include "find.h"

static void flag_error(char     *s,
                       char     *str)
{
    s = mystrcat(s, ": Ignoring unrecognised debug flag `");
    s = mystrcat(s, str);
    s = mystrcat(s, "'\n");
    write(STDOUT_FILENO, s, mystrlen(s));
    exit (1);
}

void        parse_short(int     *argc,
                        int     *i,
                        char    **argv)
{
    while ((*i) < (*argc) && (argv[(*i)][0] == '-'))
    {
        if((mystrcmp(argv[(*i)], "-L") == 1) ||
            (mystrcmp(argv[(*i)], "-P") == 1) ||
            (mystrcmp(argv[(*i)], "-O1") == 1 ) ||
            (mystrcmp(argv[(*i)], "-O2") == 1) ||
            (mystrcmp(argv[(*i)], "-O3")))
            (*i)++;
        else
            if(mystrcmp(argv[(*i)], "-D") == 1)
            {
                 if((mystrcmp(argv[(*i) + 1], "help") == 1) ||
                    (mystrcmp(argv[(*i) + 1], "tree") == 1) ||
                    (mystrcmp(argv[(*i) + 1], "stat") == 1 ) ||
                    (mystrcmp(argv[(*i) + 1], "opt") == 1) ||
                    (mystrcmp(argv[(*i) + 1], "rates")))
                     (*i) += 2;
                 else
                     flag_error(argv[0], argv[(*i) + 1]);
            }
            else
                return;
     }
}
